<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    var p1 = function() {

        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                console.log('执行任务1');
                return resolve('任务1结果');
            }, 1500);
        });

    };

    var p2 = function() {

        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                console.log('执行任务2');
                return resolve('任务2结果');
            }, 1500);
        });

    };

    var p3 = function() {

        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                console.log('执行任务3');
                return resolve('任务3结果');
            }, 1500);
        });

    };


    //异步必须创建多个 promise对象


    p1()
        .then(function(value) {
            console.log(value);
            return p2(); // 回掉时执行次下一个任务， 返回下一个任务的promiseStatus和promiseValue
        })
        .then(function(value) { // 获取上一个任务的promiseValue
            console.log(value);
            return p3();
        })
        .then(function(value) {
            console.log(value);
            console.log('end');
        });
</script>
</body>
</html>